package gui.view;

import gui.controller.AttributePanelListener;
import interfaces.IRange;

import java.awt.Color;
import java.awt.Font;
import java.util.ArrayList;
import java.util.Iterator;

import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;

import massDistribution.ContinueRange;
import massDistribution.DiscreteMeasure;
import massDistribution.DiscreteRange;
import massDistribution.Metric;
import massDistribution.MetricType;

/**
 * This code was edited or generated using CloudGarden's Jigloo
 * SWT/Swing GUI Builder, which is free for non-commercial
 * use. If Jigloo is being used commercially (ie, by a corporation,
 * company or business for any purpose whatever) then you
 * should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details.
 * Use of Jigloo implies acceptance of these licensing terms.
 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
/**
 * @author Elisa Costante
 * 
 */
public class AttributesPanel extends JPanel {

	private static final long serialVersionUID = -6675709038790581863L;

	private JLabel newAttribute;
	private JRadioButton intRadioButton;
	private JRadioButton realRadioButton;

	private JTextField validRangeTxtField;
	private JLabel validRangeLabel;
	private ButtonGroup typeRadioButtonGroup;

	private JLabel metricTypeLabel;
	private JTextField metricTxtFIeld;
	private JLabel metricName;
	private JLabel metricLabel;
	private JTextField attributeNameTxtField;
	private JLabel attributeNameLabel;
	private JButton addButton;
	private JButton removeButton;
	private JPanel attributeDefinitionPanel;
	private JPanel leftPanel;
	private JPanel rightPanel;
	private JLabel allAttributeLabel;
	private JScrollPane allAttributeScroll;
	private JTextArea rangeExplanationTxtArea;
	private JTable allAttributeTable;
	private JPanel metricPanel;
	private JRadioButton notOrderedRAdioButton;

	private AttributePanelListener listener;

	private DefaultTableModel attributeTableModel;

	private EngineMain frame;

	private JButton loadButton;

	private AbstractButton saveButton;

	private JLabel worstCaseLabel;

	private JComboBox worstCaseCombo;

	private JLabel bestCaseLabel;

	private JComboBox bestCaseCombo;

	private JPanel bestWorstPanel;

	private JButton okButton;

	private JRadioButton orderedRadioButton;

	private JPanel discreteTypePanel;

	private JPanel continuousTypePanel;

	private JLabel mediumCaselabel;

	private JTextField mediumCaseTxtField;

	public AttributesPanel(EngineMain frame) {
		super();
		this.frame = frame;
		listener = new AttributePanelListener(this);
		initPanel();

	}

	private void initPanel() {

		this.setBackground(CustomizedColor.BACK_GROUND_COLOR);

		setRightPanel();

		setLeftPanel();
		setMainPanelLayout();

	}

	private void setMainPanelLayout() {
		GroupLayout layout = new GroupLayout(this);
		this.setLayout(layout);
		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);

		SequentialGroup horizontal = layout.createSequentialGroup();

		ParallelGroup leftGroup = layout.createParallelGroup();
		leftGroup.addComponent(leftPanel, this.getWidth() / 2,
				this.getWidth() / 2, Short.MAX_VALUE);
		ParallelGroup rightGroup = layout.createParallelGroup();
		rightGroup.addComponent(rightPanel, this.getWidth() / 2, this
				.getWidth() / 2, Short.MAX_VALUE);

		horizontal.addGroup(leftGroup);
		horizontal.addGroup(rightGroup);

		SequentialGroup vertical = layout.createSequentialGroup();

		ParallelGroup leftVerticalGroup = layout.createParallelGroup();
		leftVerticalGroup.addComponent(leftPanel, this.getHeight() / 2, this
				.getHeight() / 2, Short.MAX_VALUE);

		leftVerticalGroup.addComponent(rightPanel, this.getHeight() / 2, this
				.getHeight() / 2, Short.MAX_VALUE);

		vertical.addGroup(leftVerticalGroup);

		layout.setHorizontalGroup(horizontal);
		layout.setVerticalGroup(vertical);
	}

	private void setRightPanel() {

		allAttributeLabel = new JLabel();
		allAttributeLabel.setText("All Attributes");

		loadButton = new JButton("Load");
		loadButton.setActionCommand("load");
		loadButton.addActionListener(this.listener);

		saveButton = new JButton("Save");
		saveButton.setActionCommand("save");
		saveButton.addActionListener(this.listener);

		removeButton = new JButton("Remove");
		removeButton.setActionCommand("remove");
		removeButton.addActionListener(this.listener);

		rightPanel = new JPanel();
		rightPanel.setBackground(CustomizedColor.BACK_GROUND_COLOR);

		setRightPanelLayout();

	}

	private void setLeftPanel() {

		leftPanel = new JPanel();
		leftPanel.setBackground(CustomizedColor.BACK_GROUND_COLOR);

		attributeDefinitionPanel = new JPanel();
		attributeDefinitionPanel
				.setBackground(CustomizedColor.BACK_GROUND_COLOR);

		metricPanel = new JPanel();
		metricPanel.setBackground(CustomizedColor.BACK_GROUND_COLOR);

		newAttribute = new JLabel();
		newAttribute.setText("New Attribute");
		newAttribute
				.setToolTipText("Frame for the definition of a new attribute");

		attributeNameLabel = new JLabel();
		attributeNameLabel.setText("Name");

		attributeNameTxtField = new JTextField();
		attributeNameTxtField
				.setToolTipText("insert the name of the Attribute");

		metricLabel = new JLabel();
		metricLabel.setText("Metric");

		metricName = new JLabel();
		metricName.setText("Metric Name");

		metricTxtFIeld = new JTextField();
		metricTxtFIeld.setToolTipText("Insert the name of the metric");

		metricTypeLabel = new JLabel();
		metricTypeLabel.setText("Type");

		validRangeLabel = new JLabel();
		validRangeLabel.setText("Valid IRange");

		validRangeTxtField = new JTextField();
		validRangeTxtField
				.setToolTipText("Insert the valid range E.g. 8-10; 15-20;");

		addButton = new JButton();
		addButton.setText("ADD");
		addButton.setActionCommand("add");
		addButton.setToolTipText("Add the new Attribute");
		addButton.addActionListener(this.listener);

		setRadioPanel();

		setAttributeDefinitionPanelLayout();

		setBestWorstPanel();

		setLeftPanelLayout();

	}

	/**
	 * 
	 */
	private void setRadioPanel() {
		setTypeRadioButton();
		setContinuousTypePanel();
		setDiscreteTypeJPanel();
	}

	/**
	 * 
	 */
	private void setContinuousTypePanel() {
		continuousTypePanel = new JPanel();
		continuousTypePanel.setBackground(CustomizedColor.BACK_GROUND_COLOR);

		Border border = BorderFactory.createLineBorder(Color.gray);
		border = BorderFactory.createTitledBorder(border, "Continuous Type",
				TitledBorder.CENTER, TitledBorder.CENTER);
		continuousTypePanel.setBorder(border);

		GroupLayout layout = new GroupLayout(continuousTypePanel);
		continuousTypePanel.setLayout(layout);
		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);

		ParallelGroup horizontal = layout.createParallelGroup();

		horizontal.addComponent(intRadioButton, 100, 100, Short.MAX_VALUE);
		horizontal.addComponent(realRadioButton, 100, 100, Short.MAX_VALUE);

		SequentialGroup vertical = layout.createSequentialGroup();

		vertical.addComponent(intRadioButton, 30, 30, 30);
		vertical.addComponent(realRadioButton, 30, 30, 30);

		layout.setHorizontalGroup(horizontal);
		layout.setVerticalGroup(vertical);

	}

	private ButtonGroup setTypeRadioButton() {
		if (typeRadioButtonGroup == null) {
			typeRadioButtonGroup = new ButtonGroup();

			intRadioButton = new JRadioButton("Integer");
			intRadioButton.setSelected(true);
			intRadioButton.setBackground(CustomizedColor.BACK_GROUND_COLOR);

			realRadioButton = new JRadioButton("Real");
			realRadioButton.setBackground(CustomizedColor.BACK_GROUND_COLOR);

			notOrderedRAdioButton = new JRadioButton("NOT ORDERED");
			notOrderedRAdioButton
					.setBackground(CustomizedColor.BACK_GROUND_COLOR);

			orderedRadioButton = new JRadioButton("ORDERED");
			orderedRadioButton.setBackground(CustomizedColor.BACK_GROUND_COLOR);

			typeRadioButtonGroup.add(notOrderedRAdioButton);
			typeRadioButtonGroup.add(orderedRadioButton);

			typeRadioButtonGroup.add(intRadioButton);
			typeRadioButtonGroup.add(realRadioButton);

		}

		return typeRadioButtonGroup;
	}

	/**
	 * 
	 */
	private void setDiscreteTypeJPanel() {
		discreteTypePanel = new JPanel();
		discreteTypePanel.setBackground(CustomizedColor.BACK_GROUND_COLOR);

		Border border = BorderFactory.createLineBorder(Color.gray);
		border = BorderFactory.createTitledBorder(border, "Discrete Type",
				TitledBorder.CENTER, TitledBorder.CENTER);
		discreteTypePanel.setBorder(border);

		GroupLayout layout = new GroupLayout(discreteTypePanel);
		discreteTypePanel.setLayout(layout);
		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);

		ParallelGroup horizontal = layout.createParallelGroup();

		horizontal.addComponent(notOrderedRAdioButton, 100, 100,
				Short.MAX_VALUE);
		horizontal.addComponent(orderedRadioButton, 100, 100, Short.MAX_VALUE);

		SequentialGroup vertical = layout.createSequentialGroup();

		vertical.addComponent(notOrderedRAdioButton, 30, 30, 30);
		vertical.addComponent(orderedRadioButton, 30, 30, 30);

		layout.setHorizontalGroup(horizontal);
		layout.setVerticalGroup(vertical);

	}

	private void setLeftPanelLayout() {

		GroupLayout layout = new GroupLayout(leftPanel);
		leftPanel.setLayout(layout);
		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);

		ParallelGroup horizontal = layout.createParallelGroup(Alignment.CENTER);
		horizontal.addComponent(newAttribute, 100, 100, Short.MAX_VALUE);
		horizontal.addComponent(attributeDefinitionPanel, 100, 100,
				Short.MAX_VALUE);
		horizontal.addComponent(addButton, 100, 100, 100);
		horizontal.addComponent(bestWorstPanel, 100, 100, Short.MAX_VALUE);

		SequentialGroup vertical = layout.createSequentialGroup();
		vertical.addComponent(newAttribute, 30, 30, 30);
		vertical.addComponent(attributeDefinitionPanel, 100, 100,
				Short.MAX_VALUE);
		vertical.addComponent(addButton, 30, 30, 30);
		vertical.addComponent(bestWorstPanel, 50, 70, 100);

		layout.setHorizontalGroup(horizontal);
		layout.setVerticalGroup(vertical);

	}

	private void setAttributeDefinitionPanelLayout() {
		GroupLayout layout = new GroupLayout(attributeDefinitionPanel);
		attributeDefinitionPanel.setLayout(layout);
		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);

		ParallelGroup horizontal = layout.createParallelGroup();

		// FirstLine

		SequentialGroup firstHOrizontalLine = layout.createSequentialGroup();
		firstHOrizontalLine.addComponent(attributeNameLabel, 50, 50,
				Short.MAX_VALUE);
		firstHOrizontalLine.addComponent(attributeNameTxtField, 100, 150,
				Short.MAX_VALUE);
		horizontal.addGroup(firstHOrizontalLine);

		// Second Line

		SequentialGroup secondLine = layout.createSequentialGroup();
		secondLine.addComponent(metricName, 50, 50, Short.MAX_VALUE);
		secondLine.addComponent(metricTxtFIeld, 100, 150, Short.MAX_VALUE);
		horizontal.addGroup(secondLine);

		// Third Line

		SequentialGroup thirdLine = layout.createSequentialGroup();
		thirdLine.addComponent(validRangeLabel, 50, 50, Short.MAX_VALUE);
		thirdLine.addComponent(validRangeTxtField, 100, 150, Short.MAX_VALUE);
		horizontal.addGroup(thirdLine);

		// Fourth Line
		horizontal.addComponent(getRangeExplanationTxtArea(), 100, 100,
				Short.MAX_VALUE);

		// Fifth Line
		SequentialGroup fifthLine = layout.createSequentialGroup();
		fifthLine.addComponent(continuousTypePanel, 100, 100, Short.MAX_VALUE);
		fifthLine.addComponent(discreteTypePanel, 100, 100, Short.MAX_VALUE);

		horizontal.addGroup(fifthLine);

		// Vertical
		SequentialGroup vertical = layout.createSequentialGroup();

		// FirstLine

		ParallelGroup firstVerticalLine = layout.createParallelGroup();
		firstVerticalLine.addComponent(attributeNameLabel, 30, 30, 30);
		firstVerticalLine.addComponent(attributeNameTxtField, 30, 30, 30);
		vertical.addGroup(firstVerticalLine);

		// Second Line

		ParallelGroup secondVerticalLine = layout.createParallelGroup();
		secondVerticalLine.addComponent(metricName, 30, 30, 30);
		secondVerticalLine.addComponent(metricTxtFIeld, 30, 30, 30);
		vertical.addGroup(secondVerticalLine);

		// Third Line

		ParallelGroup thirdVerticalLine = layout.createParallelGroup();
		thirdVerticalLine.addComponent(validRangeLabel, 30, 30, 30);
		thirdVerticalLine.addComponent(validRangeTxtField, 30, 30, 30);
		vertical.addGroup(thirdVerticalLine);

		// Fourth Line
		vertical.addComponent(getRangeExplanationTxtArea(), 30, 30, 130);

		// FifthLine

		ParallelGroup fifthVerticalLine = layout.createParallelGroup();
		fifthVerticalLine.addComponent(discreteTypePanel, 70, 100,
				Short.MAX_VALUE);
		fifthVerticalLine.addComponent(continuousTypePanel, 70, 100,
				Short.MAX_VALUE);
		vertical.addGroup(fifthVerticalLine);
		// horizontal.addComponent(metricPanel);

		layout.setHorizontalGroup(horizontal);
		layout.setVerticalGroup(vertical);

	}

	/**
	 * 
	 */
	private void setRightPanelLayout() {
		GroupLayout layout = new GroupLayout(rightPanel);
		rightPanel.setLayout(layout);
		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);

		ParallelGroup horizontal = layout.createParallelGroup();

		horizontal.addComponent(allAttributeLabel, 50, 100, Short.MAX_VALUE);
		horizontal.addComponent(getAllAttributeScroll(), 100, 100,
				Short.MAX_VALUE);

		SequentialGroup group2 = layout.createSequentialGroup();
		group2.addComponent(loadButton, 50, 80, 80);
		group2.addComponent(saveButton, 50, 80, 80);
		group2.addComponent(removeButton, 50, 80, 80);

		horizontal.addGroup(group2);

		SequentialGroup vertical = layout.createSequentialGroup();

		// First Column
		vertical.addComponent(allAttributeLabel, 30, 30, 30);
		vertical
				.addComponent(getAllAttributeScroll(), 50, 100, Short.MAX_VALUE);

		// Second Column
		ParallelGroup secondColumn = layout.createParallelGroup();
		secondColumn.addComponent(loadButton, 30, 30, 30);
		secondColumn.addComponent(saveButton, 30, 30, 30);
		secondColumn.addComponent(removeButton, 30, 30, 30);
		vertical.addGroup(secondColumn);

		layout.setHorizontalGroup(horizontal);
		layout.setVerticalGroup(vertical);

	}

	public JScrollPane getAllAttributeScroll() {
		if (allAttributeScroll == null) {
			allAttributeScroll = new JScrollPane();
			allAttributeScroll.setViewportView(getAllAttributeTable());
			allAttributeScroll.setEnabled(true);
			allAttributeScroll
					.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

			allAttributeScroll
					.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
		}
		return allAttributeScroll;
	}

	public JTable getAllAttributeTable() {
		if (allAttributeTable == null) {
			attributeTableModel = new DefaultTableModel(new String[] {
					"Attribute Name", "Metric Name", "Metric Type",
					"Valid Ranges" }, 0);
			allAttributeTable = new JTable(attributeTableModel);
		}
		return allAttributeTable;
	}

	public void setAllAttributeTable(DefaultTableModel attributeTableModel) {

		this.attributeTableModel = attributeTableModel;

		allAttributeTable.setModel(this.attributeTableModel);
	}

	public JTextArea getRangeExplanationTxtArea() {
		if (rangeExplanationTxtArea == null) {
			rangeExplanationTxtArea = new JTextArea();
			rangeExplanationTxtArea.setFont(new Font("Serif", Font.PLAIN, 12));

			Border border = BorderFactory.createLineBorder(Color.gray);
			border = BorderFactory.createTitledBorder(border,
					"How to use ranges", TitledBorder.CENTER,
					TitledBorder.CENTER);
			rangeExplanationTxtArea.setBorder(border);
			rangeExplanationTxtArea
					.setText("Enter either a sigle range or multiple ranges.\n"
							+ "For Example:\n"
							+ "Sigle Integer range: [2,4)\n"
							+ "Multiple Real ranges: (-INF,16.50]; [22.0,+INF);\n"
							+ "Multiple Discrete range: {true;false;unknown}\n");

		}
		return rangeExplanationTxtArea;
	}

	/**
	 * @return the serialversionuid
	 */
	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	/**
	 * @return the newAttribute
	 */
	public JLabel getNewAttribute() {
		return this.newAttribute;
	}

	/**
	 * @return the realRadioButton
	 */
	public JRadioButton getRealRadioButton() {
		return this.realRadioButton;
	}

	/**
	 * @return the intRadioButton
	 */
	public JRadioButton getIntRadioButton() {
		return this.intRadioButton;
	}

	/**
	 * @return the validRangeTxtField
	 */
	public JTextField getValidRangeTxtField() {
		return this.validRangeTxtField;
	}

	/**
	 * @return the validRangeLabel
	 */
	public JLabel getValidRangeLabel() {
		return this.validRangeLabel;
	}

	/**
	 * @return the typeRadioButtonGroup
	 */
	public ButtonGroup getTypeRadioButtonGroup() {
		return this.typeRadioButtonGroup;
	}

	/**
	 * F
	 * 
	 * @return the metricTypeLabel
	 */
	public JLabel getMetricTypeLabel() {
		return this.metricTypeLabel;
	}

	/**
	 * @return the metricTxtFIeld
	 */
	public JTextField getMetricTxtFIeld() {
		return this.metricTxtFIeld;
	}

	/**
	 * @return the metricName
	 */
	public JLabel getMetricName() {
		return this.metricName;
	}

	/**
	 * @return the metricLabel
	 */
	public JLabel getMetricLabel() {
		return this.metricLabel;
	}

	/**
	 * @return the attributeNameTxtField
	 */
	public JTextField getAttributeNameTxtField() {
		return this.attributeNameTxtField;
	}

	/**
	 * @return the attributeNameLabel
	 */
	public JLabel getAttributeNameLabel() {
		return this.attributeNameLabel;
	}

	/**
	 * @return the addButton
	 */
	public JButton getAddButton() {
		return this.addButton;
	}

	/**
	 * @return the removeButton
	 */
	public JButton getRemoveButton() {
		return this.removeButton;
	}

	/**
	 * @return the attributeDefinitionPanel
	 */
	public JPanel getAttributeDefinitionPanel() {
		return this.attributeDefinitionPanel;
	}

	/**
	 * @return the leftPanel
	 */
	public JPanel getLeftPanel() {
		return this.leftPanel;
	}

	/**
	 * @return the rightPanel
	 */
	public JPanel getRightPanel() {
		return this.rightPanel;
	}

	/**
	 * @return the allAttributeLabel
	 */
	public JLabel getAllAttributeLabel() {
		return this.allAttributeLabel;
	}

	/**
	 * @return the metricPanel
	 */
	public JPanel getMetricPanel() {
		return this.metricPanel;
	}

	/**
	 * @return the discreteRadioButton
	 */
	public JRadioButton getNotOrderedRadioButton() {
		return this.notOrderedRAdioButton;
	}

	/**
	 * @return the attributeTableModel
	 */
	public DefaultTableModel getAttributeTableModel() {
		return this.attributeTableModel;
	}

	/**
	 * @return the frame
	 */
	public EngineMain getFrame() {
		return this.frame;
	}

	/**
	 * @param metric
	 * 
	 */
	public void showInternalWorstBestFrame(Metric metric) {
		// addButton.setVisible(false);
		EngineMain.setEnabledtPanel(leftPanel, false);
		EngineMain.setEnabledtPanel(bestWorstPanel, true);

		setWorstBestComboValue(metric);

		bestWorstPanel.setVisible(true);
		EngineMain.setEnabledtPanel(bestWorstPanel, true);
	}

	/**
	 * @param metric
	 */
	@SuppressWarnings("unchecked")
	private void setWorstBestComboValue(Metric metric) {
		if (metric != null && metric.getValidRanges() != null) {
			worstCaseCombo.removeAllItems();
			bestCaseCombo.removeAllItems();
			ArrayList<IRange> allranges = metric.getValidRanges();

			if (metric.getType().equals(MetricType.INTEGER)
					|| metric.getType().equals(MetricType.REAL)) {
				for (Iterator iterator = allranges.iterator(); iterator
						.hasNext();) {
					ContinueRange iRange = (ContinueRange) iterator.next();

					worstCaseCombo.addItem(iRange.getLowerBound());
					worstCaseCombo.addItem(iRange.getUpperBound());
					bestCaseCombo.addItem(iRange.getLowerBound());
					bestCaseCombo.addItem(iRange.getUpperBound());

				}

			} else if (metric.getType().equals(MetricType.DISCRETE)) {

				// Discrete type
				for (Iterator iterator = allranges.iterator(); iterator
						.hasNext();) {
					DiscreteRange iRange = (DiscreteRange) iterator.next();
					ArrayList<DiscreteMeasure> elementList = iRange
							.getRangeElements();
					for (int i = 0; i < elementList.size(); i++) {
						worstCaseCombo.addItem(elementList.get(i).toString());
						bestCaseCombo.addItem(elementList.get(i).toString());

					}

				}
			}

		}
	}

	/**
	 * 
	 */
	private void setBestWorstPanel() {
		bestWorstPanel = new JPanel();
		bestWorstPanel.setBackground(CustomizedColor.BACK_GROUND_COLOR);

		worstCaseLabel = new JLabel("Worst Case");
		worstCaseCombo = new JComboBox();

		bestCaseLabel = new JLabel("Best Case");
		bestCaseCombo = new JComboBox();

		okButton = new JButton("ok");
		okButton.setActionCommand("ok");
		okButton.addActionListener(listener);

		mediumCaselabel = new JLabel("Medium Case");
		mediumCaseTxtField = new JTextField();

		GroupLayout layout = new GroupLayout(bestWorstPanel);
		bestWorstPanel.setLayout(layout);
		layout.setAutoCreateGaps(true);
		layout.setAutoCreateContainerGaps(true);

		ParallelGroup horizontal = layout.createParallelGroup(Alignment.CENTER);

		SequentialGroup firstLine = layout.createSequentialGroup();

		SequentialGroup rowFristGroup = layout.createSequentialGroup();
		rowFristGroup.addComponent(worstCaseLabel, 50, 100, 100);
		rowFristGroup.addComponent(worstCaseCombo, 50, 100, Short.MAX_VALUE);
		firstLine.addGroup(rowFristGroup);

		SequentialGroup rowSecondGroup = layout.createSequentialGroup();
		rowSecondGroup.addComponent(bestCaseLabel, 50, 100, 100);
		rowSecondGroup.addComponent(bestCaseCombo, 50, 100, Short.MAX_VALUE);
		firstLine.addGroup(rowSecondGroup);

		SequentialGroup rowThirdGroup = layout.createSequentialGroup();
		rowThirdGroup.addComponent(mediumCaselabel, 50, 100, Short.MAX_VALUE);
		rowThirdGroup
				.addComponent(mediumCaseTxtField, 50, 100, Short.MAX_VALUE);
		firstLine.addGroup(rowThirdGroup);

		horizontal.addGroup(firstLine);
		horizontal.addComponent(okButton, 100, 100, 100);

		SequentialGroup vertical = layout.createSequentialGroup();

		ParallelGroup firstColumn = layout.createParallelGroup();

		ParallelGroup firstColumnGroup = layout.createParallelGroup();
		firstColumnGroup.addComponent(worstCaseLabel, 30, 30, 30);
		firstColumnGroup.addComponent(worstCaseCombo, 30, 30, 30);
		firstColumn.addGroup(firstColumnGroup);

		ParallelGroup secondColumnGroup = layout.createParallelGroup();
		secondColumnGroup.addComponent(bestCaseLabel, 30, 30, 30);
		secondColumnGroup.addComponent(bestCaseCombo, 30, 30, 30);
		firstColumn.addGroup(secondColumnGroup);

		ParallelGroup thirsColumnGroup = layout.createParallelGroup();
		thirsColumnGroup.addComponent(mediumCaselabel, 30, 30, 30);
		thirsColumnGroup.addComponent(mediumCaseTxtField, 30, 30, 30);
		firstColumn.addGroup(thirsColumnGroup);

		vertical.addGroup(firstColumn);
		vertical.addComponent(okButton, 30, 30, 30);

		layout.setHorizontalGroup(horizontal);
		layout.setVerticalGroup(vertical);

		bestWorstPanel.setVisible(false);

	}

	/**
	 * @return the bestWorstPanel
	 */
	public JPanel getBestWorstPanel() {
		return this.bestWorstPanel;
	}

	/**
	 * @return the bestCaseCombo
	 */
	public JComboBox getBestCaseCombo() {
		return this.bestCaseCombo;
	}

	/**
	 * @return the worstCaseCombo
	 */
	public JComboBox getWorstCaseCombo() {
		return this.worstCaseCombo;
	}

	/**
	 * @return the listener
	 */
	public AttributePanelListener getListener() {
		return this.listener;
	}

	/**
	 * @return the orderedRadioButton
	 */
	public JRadioButton getOrderedRadioButton() {
		return this.orderedRadioButton;
	}

	/**
	 * @param orderedRadioButton
	 *            the orderedRadioButton to set
	 */
	public void setOrderedRadioButton(JRadioButton orderedRadioButton) {
		this.orderedRadioButton = orderedRadioButton;
	}

	/**
	 * @return the mediumCaseTxtField
	 */
	public JTextField getMediumCaseTxtField() {
		return this.mediumCaseTxtField;
	}

}
